package com.yyh1;

public class Calculation {
    //行为
    //加法运算
    public double add(double...  arr){
        double sum = 0.0;
        for (int i = 0; i < arr.length; i++) {
            sum+=arr[i];
        }
        return sum;
    }
    //减法运算
    public double sub(double...  arr){
        double sum = arr[0];
        for (int i = 1; i < arr.length; i++) {
            sum-=arr[i];
        }
        return sum;
    }
    //乘法运算
    public double times(double...  arr){
        double sum = arr[0];
        for (int i = 1; i < arr.length; i++) {
            sum*=arr[i];
        }
        return sum;
    }
    //除法运算
    public double div(double...  arr){
        double sum = arr[0];
        for (int i = 1; i < arr.length; i++) {
            sum/=arr[i];
        }
        return sum;
    }
}
